Encoding:

P32A

001000

rt

rs

rd

SUBUH.QB

0

1101001

101

P32A

001000

rt

rs

rd

SUBUH_R.QB

1

1101001

101

6

5

5

5

1

7

3

Format:

SUBUH[_R].QB 

Subtract Unsigned Bytes And Right Shift to Halve Results

SUBUH.QB    rd, rs, rt

DSP-R2

Subtract Unsigned Bytes And Right Shift to Halve Results

SUBUH_R.QB  rd, rs, rt

DSP-R2

Subtract Unsigned Bytes And Right Shift to Halve Results

Purpose:

Subtract Unsigned Bytes And Right Shift to Halve Results

Element-wise subtraction of two vectors of unsigned bytes, with a one-bit right shift to halve results and optional rounding.

Description:

rd = round((rs31..24 - rt31..24)>>1) || round((rs23..16 - rt23..16)>>1) || 
round((rs15..8 - rt15..8)>>1) || round((rs7..0 - rt7..0)>>1)

The four unsigned byte values in register rt are subtracted from the corresponding unsigned byte values in register rs.

Each unsigned result is then halved by shifting right by one bit position. The byte results are then written to the corresponding elements of destination register rd.

In the rounding variant of the instruction, a value of 1 is added to the result of each subtraction at the discarded bit position before the right shift.

The results of this instruction never overflow; no bits of the ouflag field in the DSPControl register are written.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBUH.QB
   ValidateAccessToDSPResources()
   tempD7..0 = ( ( 0 || GPR[rs]31..24 ) - ( 0 || GPR[rt]31..24 )) >> 1
   tempC7..0 = ( ( 0 || GPR[rs]23..16 ) - ( 0 || GPR[rt]23..16 )) >> 1
   tempB7..0 = ( ( 0 || GPR[rs]15..8 ) - ( 0 || GPR[rt]15..8 )) >> 1
   tempA7..0 = ( ( 0 || GPR[rs]7..0 ) - ( 0 || GPR[rt]7..0 )) >> 1
   GPR[rd]31..0 = tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
SUBUH_R.QB
   ValidateAccessToDSPResources()
   tempD7..0 = ( ( 0 || GPR[rs]31..24 ) - ( 0 || GPR[rt]31..24 ) + 1) >> 1
   tempC7..0 = ( ( 0 || GPR[rs]23..16 ) - ( 0 || GPR[rt]23..16 ) + 1) >> 1
   tempB7..0 = ( ( 0 || GPR[rs]15..8 ) - ( 0 || GPR[rt]15..8 ) + 1) >> 1
   tempA7..0 = ( ( 0 || GPR[rs]7..0 ) - ( 0 || GPR[rt]7..0 ) + 1) >> 1
   GPR[rd]31..0 = tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled